Creating cool Web pages with Perl by Jerry Muelver
Author:Jerry Muelver
Language: eng
Format: epub
Tags: Perl (Computer program language), World Wide Web.
Publisher: IDG Books Worldwide
Published: 1996-06-14T16:00:00+00:00
Creating Cool Web Pages with Perl
The steps for using global variables with subroutines in monum.pl are clear:
1. Assign a value to $monthNum as a test.
2. Assign a value to $myMonth outside of the subroutine.
3. Call up &moNum to start the subroutine code. The subroutine calculates a new value for $monthNum by using the value in $myMonth.
4. Check for the results by printing $monthNum.
Relying on global variables to communicate with a subroutine works and is great for particular applications, but it also produces some side-effects. First, you are restricted to using the exact variable names used within the subroutine. That fact sends you searching through your code to make sure that you have everything exactly right. Second, you are prohibited from using the subroutine's variables anywhere that could accidentally affect the results of subroutine calls from somewhere else. That restriction sends you searching through your code again.
Receiving function values through return
The data hand-off mechanism for subroutines is the reserved word return. The return function takes a value and passes it back as an assignable value to the statement that called the subroutine. The syntax is
return val;
where val is either a variable such as $monthNumor a literal value such as "1' or "All done."
To use return in &moNum, hand over the month number stored in $monthNum, using the line shown in boldface:
sub moNum f
Smonths = "JanFebMarAprMayJunJulAugSepOctNovDec SmonthNum = (index($months. SmyMonth) +3) / 3; return SmonthNum;
Now that &moNum returns a value, you are free to use any variable you want to receive the results of the month-to-number conversion. For example
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7810)
Grails in Action by Glen Smith Peter Ledbrook(7719)
Azure Containers Explained by Wesley Haakman & Richard Hooper(6861)
Configuring Windows Server Hybrid Advanced Services Exam Ref AZ-801 by Chris Gill(6860)
Running Windows Containers on AWS by Marcio Morales(6388)
Kotlin in Action by Dmitry Jemerov(5092)
Microsoft 365 Identity and Services Exam Guide MS-100 by Aaron Guilmette(5081)
Combating Crime on the Dark Web by Nearchos Nearchou(4657)
Microsoft Cybersecurity Architect Exam Ref SC-100 by Dwayne Natwick(4642)
Management Strategies for the Cloud Revolution: How Cloud Computing Is Transforming Business and Why You Can't Afford to Be Left Behind by Charles Babcock(4438)
The Ruby Workshop by Akshat Paul Peter Philips Dániel Szabó and Cheyne Wallace(4345)
The Age of Surveillance Capitalism by Shoshana Zuboff(3983)
Python for Security and Networking - Third Edition by José Manuel Ortega(3903)
The Ultimate Docker Container Book by Schenker Gabriel N.;(3568)
Learn Wireshark by Lisa Bock(3551)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3530)
Mastering Python for Networking and Security by José Manuel Ortega(3376)
Mastering Azure Security by Mustafa Toroman and Tom Janetscheck(3358)
Blockchain Basics by Daniel Drescher(3329)
